package com.example.activemqconsumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.annotation.JmsListeners;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author: wukangrong
 * @date: 2021/1/29 13:32
 * @description:
 */
@Component
@Slf4j
public class Consumer {


    @JmsListener(destination = "test.topic")
    @Async
    public void processMsg(String msg) {
        try {
            log.info("start...{}", Thread.currentThread().getName());
            log.info("process msg : {}, from {}", msg, Thread.currentThread().getName());
            TimeUnit.SECONDS.sleep(2);
            log.info("end...{}", Thread.currentThread().getName());
        } catch (InterruptedException e) {
            log.error(e.getMessage(), e);
        }
    }


}
